function correspondingTriangles=findLocalTriangle(localSequence, sites, triangles, triangleGrid)


numSequence=size(localSequence,2);
correspondingTriangles=zeros(1,numSequence);


for s=1:numSequence
    curr=localSequence(:,s);
    [x_idx, y_idx]=findIdx(curr(1), curr(2), triangleGrid);
    testTriangles=triangleGrid.grid{x_idx,y_idx};
    for t=1:length(testTriangles)
        currTriangle=triangles(testTriangles(t),:);
        if insideTriangle(sites(currTriangle(1),1:2)', sites(currTriangle(2),1:2)',sites(currTriangle(3),1:2)',curr(1:2)); 
            correspondingTriangles(s)=testTriangles(t);
            break;
        end
    end
end

end